<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
namespace core;
defined('BY_JYA') or exit('error');
class session_file {
	private $expire;
	public function __construct($expire){
		$this->expire=$expire;
		$this->check_dir();
	}
	public function open() {
		return true;
	}

	public function close() {
		return true;
	}
	protected function check_dir(){
		$session_dir=ROOT_AT.'session/'.IN;
		if(!is_dir($session)){
			cfc('files')->mkdirs($session_dir);
		}
	}
	public function read($sid){
		
		$file=ROOT_AT.'session/'.IN.'/'.$sid.'.session';
		if(is_file($file)){
			$row=file_get_contents($file);
			return $row;
		}
		return false;
		
	}
	public function write($sid, $data) {
		global $_AR;
		if(defined('NOSESSION')){
			return true;
		}
		$file=ROOT_AT.'session/'.IN.'/'.$sid.'.session';
		file_put_contents($file,$data);
		
		return true;
	}
	public function destroy($sid) {
		$file=ROOT_AT.'session/'.IN.'/'.$sid.'.session';
		@unlink($file);
		//pdo_update('core_session',array(IN=>''),array('id'=>$sid));
		return true;
	}
	public function gc($expire) {
		//pdo_delete('core_session', array('expire <'=>TIMESTAMP));
		return true;
	}
}